const express = require('express')
const { createProxyMiddleware: proxy } = require('http-proxy-middleware')
const app = express()
app.listen(3000, '0.0.0.0', () => console.log('http://localhost:3000'))

// 代理服务器要允许跨域
app.use(require('cors')())


app.get('/home', (req, res) => {
  res.send('1111')
})

app.use('/xhr', proxy({
  target: 'http://you.163.com',
  // 改变代理服务器的主机名称  host
  changeOrigin: true,
  pathRewrite: {
    // '^/api': ''
  }
}))

/* app.use('/api', proxy({
  target: 'https://i.maoyan.com',
  // 改变代理服务器的主机名称  host
  changeOrigin: true
})) */
// app.use('/api', proxy({ target: 'https://api.iynn.cn/film', changeOrigin: true }));